package com.eorchis.module.news.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.HashSet;
import java.util.Set;
import com.eorchis.core.basedao.entity.impl.AbstractBaseEntity;
import org.hibernate.annotations.GenericGenerator;
import com.eorchis.core.basedao.entity.IBaseEntity;
import com.eorchis.module.basedata.domain.BaseData;
import com.eorchis.module.newsuserlink.domain.NewsUserLink;

/**
 * Title: News<br>
 * Description: 消息管理实体对象<br>
 * Company: GoldGov<br>
 * Copyright @ 2012 GoldGov .All rights reserved.<br>
 * @author RongSL
 * @createDate 2016-05-06
 * @version $Revision$
 */
@Entity
@Table(name = "NEWS")
public class News extends AbstractBaseEntity implements IBaseEntity {
	private static final long serialVersionUID = 1L;
	/**
	 * 通用状态位：1
	 */
	public final static Integer IS_Y = new Integer(1);
	/**
	 * 通用状态位：2
	 */
	public final static Integer IS_N = new Integer(2);
	
	public final static String XXLX_PXB="xxlx_pxb";
	public final static String NEWS_TYPE="xxlx";
	
	public final static String NEWS_TYPE_CODE_XUEYUAN="xueyuan";//通知类型-学员
	public final static String NEWS_TYPE_CODE_ADMIN="guanliyuan";//通知类型-管理员
	public final static String NEWS_TYPE_CODE_ALL_USER="alluser";//通知类型-全部人员
	
	private String newsId;//消息管理ID
	private Integer sendLookState;//发送人显示状态   1：显示     2：不显示
	private String attachmentId;//附件ID
	private String newsValue;//消息内容
	private BaseData newsType;//消息类型
	private String sendUserId;//消发送人ID
	private String newsTitle;//消息标题
	private String ClassName;//班级名称
	private String fileSize;//附件大小

	private Set<NewsUserLink> newsUserList=new HashSet<NewsUserLink>();//消息发送集合

	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(name="NEWS_ID")
	/**
	 * 设置消息管理ID
	 */		
	public String getNewsId() {
		return newsId;
	}
	/**
	 * 获取消息管理ID
	 */		
	public void setNewsId(String newsId) {
		this.newsId = newsId;
	}
	@Column(name="SEND_LOOK_STATE")
	/**
	 * 设置发送人显示状态
	 */		
	public Integer getSendLookState() {
		return sendLookState;
	}
	/**
	 * 获取发送人显示状态
	 */		
	public void setSendLookState(Integer sendLookState) {
		this.sendLookState = sendLookState;
	}
	@Column(name="ATTACHMENT_ID")
	/**
	 * 设置附件ID
	 */		
	public String getAttachmentId() {
		return attachmentId;
	}
	/**
	 * 获取附件ID
	 */		
	public void setAttachmentId(String attachmentId) {
		this.attachmentId = attachmentId;
	}
	@Column(name="NEWS_VALUE")
	/**
	 * 设置消息内容
	 */		
	public String getNewsValue() {
		return newsValue;
	}
	/**
	 * 获取消息内容
	 */		
	public void setNewsValue(String newsValue) {
		this.newsValue = newsValue;
	}
	
	/**
	 * 获取消息类型
	 */		
	@ManyToOne(cascade = { javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.REFRESH }, fetch = FetchType.LAZY, optional = true)
	@JoinColumn(name = "NEWS_CODE", referencedColumnName = "DATA_CODE")
	public BaseData getNewsType() {
		return newsType;
	}

	public void setNewsType(BaseData newsType) {
		this.newsType = newsType;
	}
	
	/**
	 * 记录日志使用
	 */
	public String toString() {
		return "消息管理ID======>" + getNewsId()+"\n发送人显示状态======>" + getSendLookState()+"\n附件ID======>" + getAttachmentId()+"\n消息内容======>" + getNewsValue();
	}
	
	@OneToMany(mappedBy = "news", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	public Set<NewsUserLink> getNewsUserList() {
		return newsUserList;
	}
	public void setNewsUserList(Set<NewsUserLink> newsUserList) {
		this.newsUserList = newsUserList;
	}
	
	@Column(name="SEND_USER_ID")
	public String getSendUserId() {
		return sendUserId;
	}
	public void setSendUserId(String sendUserId) {
		this.sendUserId = sendUserId;
	}

	@Column(name="FILE_SIZE")
	public String getFileSize() {
		return fileSize;
	}
	public void setFileSize(String fileSize) {
		this.fileSize = fileSize;
	}
	@Column(name="news_title")
	public String getNewsTitle() {
		return newsTitle;
	}
	public void setNewsTitle(String newsTitle) {
		this.newsTitle = newsTitle;
	}
	@Column(name="class_name")
	public String getClassName() {
		return ClassName;
	}
	public void setClassName(String className) {
		ClassName = className;
	}
	
}
